﻿using System;
using System.Collections.Generic;
using System.Text;
using Manso.cBot.Common;
using VhaBot.Common;

namespace Manso.cBot.DefaultModules.Kos
{
    public class KosGetAllCommand : ICommand
    {
        private ListenToEnum _listenTo;
        private string _command;
        private string _help;
        private string _usage;
        private AccessControlLevel _accessLevel;

        public KosGetAllCommand()
        {
            _listenTo = ListenToEnum.Both;
            _command = "KosGetAll";
            _help = "Show you a window with all kos list information";
            _usage = "kosgetall";
            _accessLevel = AccessControlLevel.Basic;
        }

        public ListenToEnum ListenTo
        {
            get { return _listenTo; }
        }

        public string Command
        {
            get { return _command; }
        }

        public string Help
        {
            get { return _help; }
        }

        public string Usage
        {
            get { return _usage; }
        }

        public AccessControlLevel AccessLevel
        {
            get { return _accessLevel; }
        }

        public void ExecuteCommand(string[] args, string executedBy, ListenToEnum listenTo)
        {

            KosList kosList = new KosList();
            kosList.ReadXml("Kos/KosList.xml");

            TextWindow textWindow = new TextWindow();
            foreach (KosList.KosTargetRow kosTargetRow in kosList.KosTarget)
            {
                textWindow.AppendColorString("FF0000", string.Format("{0}", kosTargetRow.CharacterName));
                textWindow.AppendLineBreak();
                foreach (KosList.AddedByRow addedByRow in kosTargetRow.GetAddedByRows())
                {
                    textWindow.AppendColorString("CC00FF",addedByRow.CharacterName + " => ");
                    textWindow.AppendString(addedByRow.Comment);
                    textWindow.AppendLineBreak();
                }
                textWindow.AppendLineBreak();
            }

            cBotContext.Instance.SendMessage(textWindow.ToString("Click here for complete KOS list"), executedBy, listenTo);
        }
    }
}
